package com.ktjy.controller;


import com.ktjy.service.OrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;

@Controller
public class contrRptController {
    @Autowired
    OrdersService ordersService;

    @RequestMapping("/contrRpt/list")
    public Object contrRptList(Model model) {
        List<HashMap> hashMapList = ordersService.getMapLIst();

        List<Object> customerName =(hashMapList.stream().map(order -> {
            return order.get("odr_customer");
        }).collect(Collectors.toList()));

        model.addAttribute("customerName", customerName);
        List<Object> customerPrice = hashMapList.stream().map(order -> {
            return order.get("sumCount");
        }).collect(Collectors.toList());

        model.addAttribute("customerPrice", customerPrice);
        return "contrRpt/list";
    }

}
